import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render, formattingMin } from '/@/utils/common/renderUtils';
//列表数据
export const columns : BasicColumn[] = [
	/* {
		title: '类型',
		align: "center",
		dataIndex: 'type'
	}, */
	{
		title: '游记名称',
		align: "center",
		dataIndex: 'mainbsid_dictText'
	},
	/* 	{
			title: '回复上一级评论id',
			align: "center",
			dataIndex: 'parentreplyid'
		},
		{
			title: '主评论id，只有一个，如果是根评论，就是0',
			align: "center",
			dataIndex: 'mainreplyid'
		}, */
	{
		title: '回复内容',
		align: "center",
		dataIndex: 'replycontent',
		customRender: ({ text }) => {
			let o = JSON.parse(text)
			return o.content
		}
	},
	{
		title: '点赞数',
		align: "center",
		dataIndex: 'likenum'
	},
	{
		title: '创建时间',
		align: "center",
		dataIndex: 'createtime',
		customRender: ({ text }) => {
			return formattingMin(text)
		}
	},
	{
		title: '层级',
		align: "center",
		dataIndex: 'layoutlev'
	},
	/* 	{
			title: '用户id',
			align: "center",
			dataIndex: 'userid'
		}, */
	{
		title: '省',
		align: "center",
		dataIndex: 'city'
	},
	{
		title: '创建用户信息',
		align: "center",
		dataIndex: 'createuserinfor',
		customRender: ({ text }) => {
			let o = JSON.parse(text)
			let oo = JSON.parse(o.extInfors)
			return oo.realName || ''
		}
	},

	{
		title: '回复链',
		align: "center",
		dataIndex: 'replychain',
		customRender: ({ text }) => {
			if (text == '{}') return '';
			let o = JSON.parse(text)
			console.log(o)
			if (o.replyUser) {
				if (o.replyUser.extInfors) {
					let oo = JSON.parse(o.replyUser.extInfors)
					return '回复【' + oo.realName + '-' + o.replyContent.content + '】'
				} else {
					return '回复' + '【' + o.replyContent.content + '】'
				}
			}
		}
	},
	/*  {
	   title: '其他信息',
	   align:"center",
	   dataIndex: 'extinfor'
	  }, */
];

export const columnsGroupTeam : BasicColumn[] = [

	{
		title: '大团名称',
		align: "center",
		dataIndex: 'titleGroup',
		customRender:({text})=>{
			let o=JSON.parse(text)
			return o.mainTitle
		}
	},
	{
		title: '回复内容',
		align: "center",
		dataIndex: 'replycontent',
		customRender: ({ text }) => {
			let o = JSON.parse(text)
			return o.content
		}
	},
	{
		title: '点赞数',
		align: "center",
		dataIndex: 'likenum'
	},
	{
		title: '创建时间',
		align: "center",
		dataIndex: 'createtime',
		customRender: ({ text }) => {
			return formattingMin(text)
		}
	},
	{
		title: '层级',
		align: "center",
		dataIndex: 'layoutlev'
	},
	/* 	{
			title: '用户id',
			align: "center",
			dataIndex: 'userid'
		}, */
	{
		title: '省',
		align: "center",
		dataIndex: 'city'
	},
	{
		title: '创建用户信息',
		align: "center",
		dataIndex: 'createuserinfor',
		customRender: ({ text }) => {
			let o = JSON.parse(text)
			let oo = JSON.parse(o.extInfors)
			return oo.realName || ''
		}
	},

	{
		title: '回复链',
		align: "center",
		dataIndex: 'replychain',
		customRender: ({ text }) => {
			if (text == '{}') return '';
			let o = JSON.parse(text)
			console.log(o)
			if (o.replyUser) {
				if (o.replyUser.extInfors) {
					let oo = JSON.parse(o.replyUser.extInfors)
					return '回复【' + oo.realName + '-' + o.replyContent.content + '】'
				} else {
					return '回复' + '【' + o.replyContent.content + '】'
				}
			}
		}
	},
	/*  {
	   title: '其他信息',
	   align:"center",
	   dataIndex: 'extinfor'
	  }, */
];


export const columnsMain : BasicColumn[] = [

	{
		title: '小团名称',
		align: "center",
		dataIndex: 'titleGroup',
	},
	{
		title: '回复内容',
		align: "center",
		dataIndex: 'replycontent',
		customRender: ({ text }) => {
			let o = JSON.parse(text)
			return o.content
		}
	},
	{
		title: '点赞数',
		align: "center",
		dataIndex: 'likenum'
	},
	{
		title: '创建时间',
		align: "center",
		dataIndex: 'createtime',
		customRender: ({ text }) => {
			return formattingMin(text)
		}
	},
	{
		title: '层级',
		align: "center",
		dataIndex: 'layoutlev'
	},
	/* 	{
			title: '用户id',
			align: "center",
			dataIndex: 'userid'
		}, */
	{
		title: '省',
		align: "center",
		dataIndex: 'city'
	},
	{
		title: '创建用户信息',
		align: "center",
		dataIndex: 'createuserinfor',
		customRender: ({ text }) => {
			let o = JSON.parse(text)
			let oo = JSON.parse(o.extInfors)
			return oo.realName || ''
		}
	},

	{
		title: '回复链',
		align: "center",
		dataIndex: 'replychain',
		customRender: ({ text }) => {
			if (text == '{}') return '';
			let o = JSON.parse(text)
			console.log(o)
			if (o.replyUser) {
				if (o.replyUser.extInfors) {
					let oo = JSON.parse(o.replyUser.extInfors)
					return '回复【' + oo.realName + '-' + o.replyContent.content + '】'
				} else {
					return '回复' + '【' + o.replyContent.content + '】'
				}
			}
		}
	},
	/*  {
	   title: '其他信息',
	   align:"center",
	   dataIndex: 'extinfor'
	  }, */
];

//查询数据
export const searchFormSchema : FormSchema[] = [
];
//表单数据
export const formSchema : FormSchema[] = [
	{
		label: '类型',
		field: 'type',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入类型!' },
			];
		},
	},
	{
		label: '主业务id',
		field: 'mainbsid',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入主业务id!' },
			];
		},
	},
	{
		label: '回复上一级评论id',
		field: 'parentreplyid',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入回复上一级评论id!' },
			];
		},
	},
	{
		label: '主评论id，只有一个，如果是根评论，就是0',
		field: 'mainreplyid',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入主评论id，只有一个，如果是根评论，就是0!' },
			];
		},
	},
	{
		label: '点赞数',
		field: 'likenum',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入点赞数!' },
			];
		},
	},
	{
		label: '创建时间',
		field: 'createtime',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入创建时间!' },
			];
		},
	},
	{
		label: '第几层级，一共3层级，回复三层级，则自身就是3层级',
		field: 'layoutlev',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入第几层级，一共3层级，回复三层级，则自身就是3层级!' },
			];
		},
	},
	{
		label: '用户id',
		field: 'userid',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入用户id!' },
			];
		},
	},
	{
		label: '城市',
		field: 'city',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入城市!' },
			];
		},
	},
	{
		label: '创建用户信息',
		field: 'createuserinfor',
		component: 'InputTextArea',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入创建用户信息!' },
			];
		},
	},
	{
		label: '回复内容',
		field: 'replycontent',
		component: 'InputTextArea',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入回复内容!' },
			];
		},
	},
	{
		label: '回复链。例如  “xxx  回复 yyy ”：',
		field: 'replychain',
		component: 'InputTextArea',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入回复链。例如  “xxx  回复 yyy ”：!' },
			];
		},
	},
	{
		label: '其他信息',
		field: 'extinfor',
		component: 'InputTextArea',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入其他信息!' },
			];
		},
	},
	// TODO 主键隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData) : FormSchema[] {
	// 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
	return formSchema;
}